package com.pocket.demo.business.controller;

import com.pocket.demo.base.api.R;
import com.pocket.demo.business.controller.dto.UserLoginDto;
import com.pocket.demo.business.service.impl.UserDetailsServiceImpl;
import com.pocket.demo.core.i18n.MessageSourceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;

@Tag(name = "用户登录模块", description = "用户登录相关接口")
@Validated
@RestController
@RequestMapping("/user")
public class AuthController {

    @Resource
    private UserDetailsServiceImpl userDetailsService;
    @Resource
    private MessageSourceService messageSourceService;

    @Operation(summary = "用户登录", description = "用户登录")
    @RequestMapping(value = {"/login"}, method = {RequestMethod.POST})
    public R login(@RequestBody UserLoginDto user) {
        return messageSourceService.getOkResult();
    }


    @Operation(summary = "用户登出", description = "用户登出")
    @RequestMapping(value = {"/logout"}, method = {RequestMethod.POST})
    public R logout(HttpServletRequest request){

        return messageSourceService.getOkResult();
    }
}

